package demo;

import cn.hutool.core.lang.Console;
import cn.hutool.core.util.StrUtil;
import demo.controller.OutputController;
import lombok.SneakyThrows;

import javax.swing.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.Arrays;
import java.util.List;

/**
 * @author songx
 * @date 2019/7/3 23:12
 */
public class MouseClickOutPutCurrentMonthEnter implements MouseListener {

    @SneakyThrows
    @Override
    public void mouseClicked(MouseEvent e) {

        String outPutMonth = Main.outPutMonth.getText().trim();
        if (StrUtil.isBlank(outPutMonth)) {
            JOptionPane.showMessageDialog(null, "导出月份不能为空！");
            return;
        }

        String currentWorkDays = Main.currentWorkDays.getText().trim();
        if (StrUtil.isBlank(currentWorkDays)) {
            JOptionPane.showMessageDialog(null, "当前月的标准出勤天数不能为空！");
            return;
        }

        String restInWeekList = Main.restInWeekList.getText().trim();
        if (StrUtil.isNotBlank(restInWeekList)) {
            try {
                List<String> currentWorkDaysList = Arrays.asList(restInWeekList.split(","));
            } catch (Exception exception) {
                JOptionPane.showMessageDialog(null, "第三个输入框的输入数据格式有错误");
                return;
            }
        }

        String workInWeekEndList = Main.workInWeekEndList.getText().trim();
        if (StrUtil.isNotBlank(workInWeekEndList)) {
            try {
                List<String> workInWeekEndListList = Arrays.asList(workInWeekEndList.split(","));
            } catch (Exception exception) {
                JOptionPane.showMessageDialog(null, "第四个输入框的输入数据格式有错误");
                return;
            }
        }

        OutputController outputController = new OutputController();
        outputController.outputExcel(Integer.parseInt(outPutMonth), workInWeekEndList, restInWeekList, currentWorkDays);
        Console.error(" ---------     响应 结束  ---------");
    }

    @Override
    public void mousePressed(MouseEvent e) {

    }

    @Override
    public void mouseReleased(MouseEvent e) {

    }

    @Override
    public void mouseEntered(MouseEvent e) {

    }

    @Override
    public void mouseExited(MouseEvent e) {

    }
}
